babl/base: model-gray, avoid potential NaN
authorØyvind Kolås <pippin@gimp.org>
Thu, 14 Sep 2017 16:32:09 +0000 (18:32 +0200)
committerØyvind Kolås <pippin@gimp.org>
Thu, 14 Sep 2017 16:32:23 +0000 (18:32 +0200)
babl/base/model-gray.c

index d2cf0607805c1294661bd0d1072a91d3a9f34753..6a2764ee3df0de9e9bd4b1b695ee89935780b894 100644 (file)
@@ -499,7 +499,11 @@ gray_gamma_2_2_premultiplied2rgba (Babl *conversion,
       double alpha = ((double *) src)[1];
       double luminance;
 
-      luma      = luma / alpha;
+      if (alpha > BABL_ALPHA_THRESHOLD)
+        luma      = luma / alpha;
+      else
+        luma      = 0.0;
+
       luminance = babl_trc_to_linear (trc, luma);
 
       ((double *) dst)[0] = luminance;